import 'dart:async';
import 'dart:io';

import 'package:flutter/services.dart';

class BuglyPlugin {
  static const MethodChannel _channel = const MethodChannel('bugly_plugin');

  static Future<String> get platformVersion async {
    final String version = await _channel.invokeMethod('getPlatformVersion');
    return version;
  }

  static Future<bool> setApp({String androidAppId, String iosAppId}) {
    if (Platform.isAndroid) {
      return _channel.invokeMethod("setAppId", {'app_id': androidAppId});
    } else if (Platform.isIOS) {
      return _channel.invokeMethod("setAppId", {'app_id': iosAppId});
    }
  }

  static postException(error, stack) {
    _channel.invokeMethod("postException",
        {'error': error.toString(), 'stack': stack.toString()});
  }
}
